/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-29 18:38:29
 * @Description  : 系统相关的全局状态
 */
import { defineStore } from 'pinia'
import { MENU_ACTIVE, DEP_SPLIT_SIZE } from '@/constants'
import { getItem, setItem } from '@/utils/storage'

export default defineStore('settings', {
  state() {
    return {
      menuActive: getItem(MENU_ACTIVE),
      depSplitSize: +getItem(DEP_SPLIT_SIZE) || 0.2,
      dateFormat: 'YYYY-MM-DD HH:mm:ss'
    }
  },
  actions: {
    setMenuActiveIndex(item: any) {
      this.menuActive = item
      setItem(MENU_ACTIVE, item)
    },
    setDepSplitSize(size: number) {
      this.depSplitSize = size
      setItem(DEP_SPLIT_SIZE, '' + size)
    },
    setFormat(dateFormat: string) {
      this.dateFormat = dateFormat
    }
  }
})
